package xmlParser;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public class XmlParser {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		DocumentBuilderFactory domfac=DocumentBuilderFactory.newInstance();
		 InputStream is=null;
		try {
			DocumentBuilder dombuilder=domfac.newDocumentBuilder();
			 is=new FileInputStream("examplediagram.xml");
			 Document doc=dombuilder.parse(is);
			 Element root=doc.getDocumentElement();
			 for(int i=0;i<root.getChildNodes().getLength();i++){
				 org.w3c.dom.Node node=root.getChildNodes().item(0);
				 node.getNodeName();
			 }
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				is.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
